Controlling the LED blink rate with the potentiometer interfacing with Arduino
INSTRUCTIONS
Step-1(Info.)
1.)
Source
2.)
Target
Note:
Make Connections First, Then move to the code Compilation
Step-2 (Connections)
1.)Drag and drop BreadBoard,Arduino and all other Components first.
2.)Connect
Pin 1
with
Pin 2
of breadboard..
3.)Connect
source Pin
of LED with
Pin 3
of Breadboard.. And
target Pin
of LED with
Pin 2
of Breadboard
4.)Connect
Pin 4
of breadboard with
Pin 11
of Arduino.
5.)Connect
Pin 5
of breadboard with
Pin 9
of breadboard.
6.)Connect
Gnd Pin
of Arduino with
Pin 6
of Breadboard & Connect
Pin (Vin)
of arduino with
Pin 7
of Breadboard.
7.)Connect
Pin 8
of breadboard with
Pin (A1)
of arduino.
8.)Click on
"CHECK"
button to check the connections.
Step-3 (Code Compilation)
1.) Set the pinMode of ledPin as
"OUTPUT"
2.) Set the ledPin to
"HIGH"
.
3.) Set the ledPin as
"LOW"
.
4.) Click on
"COMPILE"
to compile and run the code.
5.)
Click
on Potentiometer,to cahnge the rate of LED.
Components
Potentiometer
LED
Resister 1
Arduino
BreadBoard
3
4
7
8
9
1
2
5
6
Bread Board
LED
Potentiometer
Name :
Resister1
Value
1 k ohm Resister
Arduino UNO
Code Compiler
const int
potPin = A1;
const int
ledPin = 11;
int
val = 0;
void
setup() {
pinMode
(ledPin,
);
Serial.
begin(9600);
}
void
loop() {
val =
analogRead
(potPin);
digitalWrite
(ledPin,
); //HIGH
delay
(val);
digitalWrite
(ledPin,
); //LOW
delay
(val);
Serial.
println
(val);
}
CHECK
RESET
COMPILE
PRINT
© 2024 | Virtual Labs, IIT Roorkee